#include<iostream>
#include<stack>

using namespace std;

stack<int> sta;

char F[]="0123456789ABCDEFGHIJ";

int main()
{
	int n,R;
	cin>>n>>R;
	cout<<n<<"=";
	while(n!=0)
	{
		int tmp=n%R;
		n/=R;
		if(tmp<0)
			tmp-=R,n++;
		sta.push(tmp);
	}
	while(!sta.empty())
	{
		cout<<F[sta.top()];
		sta.pop();
	}
	cout<<"(base"<<R<<")";
	return 0;
}